import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutterhello/controller/Controller.dart';
import 'package:flutterhello/util/host_util.dart';
import 'package:flutterhello/widgets/tips_card.dart';
import 'package:get/get.dart';

class MyJoinTeamPage extends StatelessWidget {
  final controller = Get.put(Controller());
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: PreferredSize(
        child: AppBar(
          title: Text('我加入的团队'),
          centerTitle: true,
        ),
        preferredSize: Size.fromHeight(50),
      ),
      body: EasyRefresh.custom(
        slivers: <Widget>[
          SliverList(
            delegate: SliverChildBuilderDelegate(
              (context, index) {
                return Padding(
                  padding: EdgeInsets.only(
                    left: 20,
                    right: 20,
                  ),
                  child: Column(
                    children: [
                      SizedBox(
                        height: 10,
                      ),
                      GestureDetector(
                        child: TipsCard(
                          favicon: HostUtil.getHost() +
                              controller.myJoinGroup[index]['favicon'],
                          name: controller.myJoinGroup[index]['groupname'],
                        ),
                        onTap: () {
                          Get.toNamed('/team',
                              arguments: controller.myJoinGroup[index]);
                        },
                      ),
                    ],
                  ),
                );
              },
              childCount: controller.myJoinGroup.length,
            ),
          )
        ],
      ),
    );
  }
}
